import { Terminal, Uri } from "vscode";
import { EQEnvironment } from "../../eqEnvironments/info";
import { IEventNamePropertyMapping } from "../../telemetry";
import { Resource } from "../types";

export const ITerminalHelper = Symbol('ITerminalHelper');

export interface ITerminalHelper {
  identifyTerminalShell(terminal?: Terminal): TerminalShellType;
  getEnvironmentActivationCommands(
    terminalShellType: TerminalShellType,
    resource?: Uri,
    interpreter?: EQEnvironment,
): Promise<string[] | undefined>;
  getEnvironmentActivationShellCommands(
    resource: Resource,
    shell: TerminalShellType,
    interpreter?: EQEnvironment,
): Promise<string[] | undefined>;
}

export const ITerminalActivationHandler = Symbol('ITerminalActivationHandler');
export interface ITerminalActivationHandler {
    handleActivation(
        terminal: Terminal,
        resource: Uri | undefined,
        preserveFocus: boolean,
        activated: boolean,
    ): Promise<void>;
}

export enum TerminalShellType {
  powershell = 'powershell',
  powershellCore = 'powershellCore',
  commandPrompt = 'commandPrompt',
  gitbash = 'gitbash',
  bash = 'bash',
  zsh = 'zsh',
  ksh = 'ksh',
  fish = 'fish',
  cshell = 'cshell',
  tcshell = 'tshell',
  wsl = 'wsl',
  xonsh = 'xonsh',
  other = 'other',
}
export enum TerminalActivationProviders {
  bashCShellFish = 'bashCShellFish',
  commandPromptAndPowerShell = 'commandPromptAndPowerShell',
  pyenv = 'pyenv',
  conda = 'conda',
  pipenv = 'pipenv',
}
export const ITerminalActivationCommandProvider = Symbol('ITerminalActivationCommandProvider');

export interface ITerminalActivationCommandProvider {
    isShellSupported(targetShell: TerminalShellType): boolean;
    getActivationCommands(resource: Uri | undefined, targetShell: TerminalShellType): Promise<string[] | undefined>;
    getActivationCommandsForInterpreter(
        pythonPath: string,
        targetShell: TerminalShellType,
    ): Promise<string[] | undefined>;
}

export type ShellIdentificationTelemetry = IEventNamePropertyMapping['TERMINAL_SHELL_IDENTIFICATION'];

export const IShellDetector = Symbol('IShellDetector');

export interface IShellDetector {

    readonly priority: number;
    identify(telemetryProperties: ShellIdentificationTelemetry, terminal?: Terminal): TerminalShellType | undefined;
}


